﻿using System.Web;
using Grishko.SerilizeTools;
using Grishko.DataTier.SqlSentence;
using OutdoorLib.BaseEntity.Face;
using OutdoorLib.BaseEntity.Infrastructure;
using OutdoorLib.BaseEntity.Constraction;
using OutdoorLib.BaseEntity.Dictionary;
using OutdoorLib.BaseEntity.WS;

namespace OutdoorLib.BaseEntity.Filters
{
    /// <summary>
    /// Список сотрудников 
    /// </summary>
    [TagNameInfo(TagName = "ConstractionListFilter")]
    public class ConstractionListFilter : Filter
    {
        public const string qConstractionType = "ConstractionType";

        public class ConstractionListEngine : ScriptEngine
        {
            public ConstractionListEngine(ScriptEngine.TScriptEngineSrchInfo Settings) : base(Settings) { }
            public override string GetScript()
            {

                if (null != HttpContext.Current.Request[qConstractionType])
                {                    
                    string s=HttpContext.Current.Request[qConstractionType];
                    TreeDictionaryItem w = wsDictionary.GetTreeDictionaryItem(TreeDictionaryItem.TreeDictionary_ConstractionType);
                    TreeDictionaryItemValue v= w.BuildValue(s);
                    WordFieldValue_TreeValue  val=new WordFieldValue_TreeValue() { Value = v};
                    MandatoryConditions.AddMandatoryCondition_Eq(qConstractionType, val);
                }

                return base.GetScript();
            }

        }

        public override string ObjectPageKey
        {
            get
            {
                return "PageKey_ConstractionEditor";
            }
        }


        public ConstractionListFilter()
        {
            ScriptEngine.TScriptEngineSrchInfo Settings = new ScriptEngine.TScriptEngineSrchInfo();
            Settings.EntityType = typeof(ConstractionEntity);
            Settings.SqlFunction = "GetConstractionObjectPropertyStorage()";
            Where = new ConstractionListEngine(Settings);
        }
    }
}